function register() {
    var mobile = $.trim($("input[name=mobile]").val());
    var code = $.trim($("input[name=code]").val());
    var password = $.trim($("input[name=password]").val());
    var rePassword = $.trim($("input[name=repassword]").val());
    if (mobile === "") {
        toast("请输入手机号！");
        return false;
    }
    if (code === "") {
        toast("请输入验证码！");
        return false;
    }
    if (password === "") {
        toast("请输入密码！");
        return false;
    }
    if (password !== rePassword) {
        toast("密码不一致！");
        return false;
    }
    ajax({
        url: "/api/user/register",
        type: "post",
        dataType: "json",
        headers: {},
        data: new RegisterBean(mobile, md5(password).toUpperCase(), code, getClientInfo(), osName()),
        success: function (result) {
            setLocalItem("user", new AppUserBean(result.data));
            closeWebview("account-login");
            closeWebview("account-register");
            closeWebview();
        }
    });
}

var isSending = 0;

function send(_this) {
    if (isSending) {
        return false;
    } else {
        isSending = 60;
        var mobile = $.trim($("input[name=mobile]").val());
        if (mobile === '') {
            toast('请填写手机号！');
            isSending = 0;
            return false;
        }
        ajax({
            url: "/api/sms/vfCode",
            type: "post",
            dataType: "json",
            headers: {},
            data: {mobile: mobile, type: 'register'},
            success: function (result) {
                toast(result.msg);
            }
        });
        var $this = $(_this);
        $this.html(isSending + "S");
        var interval = setInterval(function () {
            if (isSending) {
                $this.html((--isSending) + "S");
            } else {
                $this.html('获取验证码');
            }
        }, 1000);
    }
}